package tom.vertx.core.demo04;

import io.vertx.core.buffer.Buffer;

/**
 * @author ZHUFEIFEI
 */
public class BufferDemo {

  public static void main(String[] args) {
    Buffer buffer = Buffer.buffer("hello world", "UTF-8");
    System.out.println(buffer.getString(0, 5));
    buffer.appendInt(123);
    System.out.println(buffer.getInt(11));

    //set by index
    buffer.setDouble(15, 123);
    System.out.println(buffer.getDouble(15));

    for (int i=0; i<buffer.length(); i++) {
//      System.out.println("index : " + i + " value : " + buffer.getInt(i));
    }

    //slice后的buffer定长, 不可以再append数据
    System.out.println(buffer.slice().setInt(18,345));
    System.out.println(buffer.appendInt(890));
    System.out.println(buffer.getInt(18));

  }
}
